<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:pr="http://primefaces.prime.com.tr/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:cc="http://java.sun.com/jsf/composite">

    <!-- INTERFACE -->
    <cc:interface>
        <cc:attribute name="source" required="true"/>
    </cc:interface>

    <!-- IMPLEMENTATION -->
    <cc:implementation>
        <h:form>
            <pr:dataTable id="products" value="#{cc.attrs.source}" var="product">

                <pr:column sortBy="#{product.articleNumber}">
                    <f:facet name="header">
                        <h:outputText value="Product#"/>
                    </f:facet>
                    <h:outputText value="#{product.articleNumber}"/>
                </pr:column>

                <pr:column sortBy="#{product.name}">
                    <f:facet name="header">
                        <h:outputText value="Name"/>
                    </f:facet>
                    <h:outputText value="#{product.name}"/>
                </pr:column>

                <pr:column sortBy="#{product.manufacturer}">
                    <f:facet name="header">
                        <h:outputText value="Manufacturer"/>
                    </f:facet>
                    <h:outputText value="#{product.manufacturer}"/>
                </pr:column>

                <pr:column sortBy="#{product.category}">
                    <f:facet name="header">
                        <h:outputText value="Category"/>
                    </f:facet>
                    <h:outputText value="#{product.category}"/>
                </pr:column>

                <pr:column sortBy="#{product.attr1}">
                    <f:facet name="header">
                        <h:outputText value="Attribute 1"/>
                    </f:facet>
                    <h:outputText value="#{product.attr1}"/>
                </pr:column>
                <pr:column sortBy="#{product.attr2}">
                    <f:facet name="header">
                        <h:outputText value="Attribute 2"/>
                    </f:facet>
                    <h:outputText value="#{product.attr2}"/>
                </pr:column>

                <pr:column sortBy="#{product.visible}">
                    <f:facet name="header">
                        <h:outputText value="Main product"/>
                    </f:facet>
                    <h:outputText rendered="#{product.visible}" value="YES" />  
                </pr:column>

                <pr:column sortBy="#{product.price}">
                    <f:facet name="header">
                        <h:outputText value="Price"/>
                    </f:facet>
                    <h:outputText value="#{product.price}"/>
                </pr:column>

                <pr:column sortBy="#{product.discount}">
                    <f:facet name="header">
                        <h:outputText value="Discount"/>
                    </f:facet>
                    <h:outputText value="#{product.discount}"/>
                </pr:column>

                <pr:column>
                    <f:facet name="header">
                        <h:outputText value="Edit"/>
                    </f:facet>
                    <h:commandButton value="Edit Product" action="#{productBacking.editProduct(product)}"/>
                </pr:column>
            </pr:dataTable>
        </h:form>
    </cc:implementation>
</html>